﻿using System;
using System.Text;
using System.Collections.Generic;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Chaliy.DbPro.Generators.TextAuthoring;
using Chaliy.DbPro.Generators.Tests.TextAuthoring.Mocks;

namespace Chaliy.DbPro.Generators.Tests.TextAuthoring
{	
	[TestClass]
	public class RandomParagraphAuthorTests
	{		
		[TestMethod]
		public void TestNormalFlowGenerate()
		{
			const string sentance = "Test Sentance!";
			IParagraphAuthor author = new RandomParagraphAuthor(new MockSentanceAuthor(sentance))
			{
				MinLength = 1,
				MaxLength = 1
			};

			string result = author.Generate();

			Assert.AreEqual(
				sentance, result
				);
		}

		[TestMethod]
		public void TestNormalFlowGenerateSapace()
		{
			const string sentance = "Test Sentance!";
			IParagraphAuthor author = new RandomParagraphAuthor(new MockSentanceAuthor(sentance))
			{
				MinLength = 2,
				MaxLength = 2
			};

			string result = author.Generate();

			Assert.AreEqual(
				(sentance.Length * 2) + 1, // 2 is because two sentances, 1 is single seprator
				result.Length,
				"Generated paragraph does not has space between sentances."
				);
		}

		[TestMethod]
		[DeploymentItem(DeploymentConstants.GeneratorsDll)]
		[ExpectedException(typeof(ArgumentNullException))]
		public void TestConstructorWithEmptyArguments()
		{
			new RandomParagraphAuthor(null);
		}
	}
}
